package date.Exa6;

import java.time.DayOfWeek;
import java.time.LocalDate;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.time.format.FormatStyle;
import java.time.format.TextStyle;
import java.util.Locale;

/**
 * 日期时间格式化和解析学习
 */
public class DateTimeFormatterStudy {
    public static void main(String[] args) {
        ZonedDateTime apollo = ZonedDateTime.of(1969,7,16,9,32,0,0, ZoneId.of("Asia/Shanghai"));

        String formatted = DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(apollo);
        System.out.println(formatted);

        DateTimeFormatter formatter = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.LONG);
        formatted = formatter.format(apollo);
        System.out.println(formatted);

        formatted = formatter.withLocale(Locale.FRANCE).format(apollo);
        System.out.println(formatted);

        formatter = DateTimeFormatter.ofPattern("E yyyy-MM-dd HH:mm:ss");
        formatted = formatter.format(apollo);
        System.out.println(formatted);

        LocalDate churchsBirthday = LocalDate.parse("1903-06-14");
        System.out.println(churchsBirthday);

        apollo = ZonedDateTime.parse("1969-07-16 09:32:00-0400",DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ssxx"));
        System.out.println(apollo);

        for(DayOfWeek w: DayOfWeek.values()){
            System.out.print(w.getDisplayName(TextStyle.SHORT,Locale.ENGLISH)+" ");
        }
    }
}
